<template>
	<view class="page">
		<view class="main center">
			<view class="title">验证码将发送到{{ mobile }}</view>
			<view class="main-code">
				<tn-verification-code-input v-model="code" :maxLength="6" :dotFill="true"></tn-verification-code-input>
			</view>
			<view class="main-tips flex">
				<image src="@/static/img/select1.png" v-if="!isSelect" @click="isSelect = !isSelect" mode=""></image>
				<image src="@/static/img/select2.png" v-else @click="isSelect = !isSelect" mode=""></image>
				<view>
					<text style="color:#333;" @click="isSelect = !isSelect">我已同意并仔细阅读关于</text>
					<text @click="apifun.navigate('/pages/my/accountAgreement')">《账号注销协议》</text>
				</view>
			</view>
			<view class="btn" @click="confirm">确认注销</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				mobile: '',
				isSelect: false,
				code: ''
			};
		},
		onLoad() {
			this.mobile = uni.getStorageSync('usermsg').mobile;
		},
		methods: {
			confirm() {
				if (!this.code) {
					return this.apifun.toast('请先填写验证码')
				}
				if (!this.isSelect) {
					return this.apifun.toast('请先同意勾选协议')
				}
				let sendData = {
					sms_code:this.code
				};
				this.apifun.unirequest('/partner/user/writeOff','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						uni.clearStorageSync();
						this.code = '';
						this.isSelect = false;
						this.apifun.toast(res.msg)
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/start/login'
							})
						}, 1500)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		.title {
			margin-top: 310rpx;
			font-size: 36rpx;
			font-weight: bold;
		}

		.main-code {
			margin-top: 130rpx;
		}

		.main-tips {
			margin: 440rpx 0 0 120rpx;
			font-size: 24rpx;
			color: #666666;

			image {
				width: 22rpx;
				height: 22rpx;
				margin-right: 10rpx;
			}

			text {
				color: #0E71EB;
			}
		}

		.btn {
			margin-top: 40rpx;
			width: 550rpx;
		}
	}
</style>